/**
 * Created by Oswald on 2016/12/27.
 */


;(function ($){
    //带有清除按钮的输入框
    $.fn.inputWithClear = function(option){

        return this.each(function (){
            var $this = $(this);

            var thisInput = $this.find("input");
            var thisSpan = $this.find("span");

            thisInput.keyup(function() {
                var valueText = thisInput.val();
                if(valueText == "") {
                    thisSpan.css("display","none");
                }else {
                    thisSpan.css("display","inline-block");
                };
            });

            thisSpan.click(function() {
                thisInput.val("").focus();
                thisSpan.css("display","none");
            });

        })

    }

    //弹出框的取消按钮
    $.fn.closeLayerBtn = function(option){
        return this.each(function (){
            var $this = $(this);

            var thisDiv = $this.parents("div .layui-layer-content");
            var i = thisDiv.attr("index");
            $this.click(function() {
                ibcpLayer.Close(i);
            });
        })
    }

    //隐藏table的checkbox
    $.fn.tableHideCheckbox = function(option){
        //return this.each(function(){
            var $this = $(this);
            var th = $this.find('thead').find('.bs-checkbox');
            th.css('width','1px');

            var td = $this.find('tbody').find('.bs-checkbox');

            td.each(function(){
                $(this).css('width','1px');
                $(this).css("padding","0px");

                var ch =  $(this).find('input');
                ch.css('width','0px');
            });
        //})

    }

})(jQuery);

$(function (){
    $("div.input-group").inputWithClear();
});